package com.Bigbluebook.Service;

import com.Bigbluebook.api.ApiConstants;
import com.Bigbluebook.entity.ApiResponse;
import com.Bigbluebook.entity.Comment;
import com.Bigbluebook.entity.Follow;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Body;
import retrofit2.http.POST;
import retrofit2.http.Query;

public class FollowApiService {
    private FollowService followService;
    private Retrofit retrofit;
    private Gson gson;
    public FollowApiService(){
        gson = new GsonBuilder()
                .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
                .create();
        retrofit = new Retrofit.Builder()
                .baseUrl(ApiConstants.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();
        followService = retrofit.create(FollowService.class);
    }
    public void followUser(long followerId,long followeeId,Callback<Follow> callback){
        Call<Follow> call = followService.followUser(followerId,followeeId);
        call.enqueue(callback);
    }

    public void unfollowUser(long followerId,long followeeId,Callback<Follow> callback){
        Call<Follow> call = followService.unfollowUser(followerId,followeeId);
        call.enqueue(callback);
    }

    public void isfollowed(long followerId,long followeeId,Callback<Follow> callback){
        Call<Follow> call = followService.isFollowed(followerId,followeeId);
        call.enqueue(callback);
    }

    public void getFollowers(long followerId, Callback<ApiResponse<List<Follow>>> callback) {
        Call<ApiResponse<List<Follow>>> call = followService.getFollowers(followerId);
        call.enqueue(callback);
    }
}
